package main;

import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.core.behaviours.TickerBehaviour;
import jade.lang.*;
import jade.lang.acl.ACLMessage;

public class TimeAgent extends Agent {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6490233245002113642L;

	@Override
	protected void setup() {

		addBehaviour(new OfferServerBeaviour());
	}

	private class OfferServerBeaviour extends CyclicBehaviour {
		/**
		 * 
		 */
		private static final long serialVersionUID = -4188886565496082602L;

		@Override
		public void action() {
			ACLMessage msg = myAgent.receive();
			if (msg != null) {
				String content = msg.getContent();
				ACLMessage reply = msg.createReply();
				reply.setPerformative(ACLMessage.INFORM);
				reply.setContent(content + ":" + myAgent.getName());
				myAgent.send(reply);
				System.out.println(content);
			} else {
				block();
			}
		}
	}
}
